<?php
class VipUserModel extends Model {
	var $_table = 'vip_user';
	var $uid_nak; //INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '会员编号',
	var $account_sr; //VARCHAR(32) NOT NULL COMMENT '账户',
	var $email_sr; //VARCHAR(128) NOT NULL COMMENT '邮件地址',
	var $gname_sr = 'vip'; //INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '组ID',
	var $reg_time_Tr; //INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '注册时间',
	var $reg_ip_sr; //VARCHAR(128) NOT NULL COMMENT '注册IP',
	var $reg_sign_s = ''; //VARCHAR(16) NULL COMMENT '注册来源',
	var $passwd_s; //VARCHAR(32) NULL COMMENT '密码',
	var $sns_from_s; //VARCHAR(16) NULL COMMENT '同步登录',
	var $sns_uid_sr = ''; // VARCHAR(64) '' COMMENT '第三方用户编号',
	var $status_sr = 'actived'; //ENUM('actived', 'new', 'inactived') NOT NULL DEFAULT 'actived' COMMENT '状态',
	var $last_login_uT; //INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '最后一次登录时间',
	var $last_ip_sr; //VARCHAR(128) NOT NULL COMMENT '最后一次登录IP',
	

	//检验用户账户是否存在
	public function check_uname($value, $data) {
		if ($value == $data ['old_account']) {
			return true;
		}
		$where ['account'] = $value;
		if (! empty ( $data ['uid'] )) {
			$where ['uid !='] = $data ['uid'];
		}
		return $this->exist ( $where ) ? "会员名已经存在" : apply_filter ( 'check_vip_account', true, $value, $data );
	}
	//检验邮箱是否存在
	public function check_email($value, $data) {
		if ($value == $data ['old_email']) {
			return true;
		}
		$where ['email'] = $value;
		if (! empty ( $data ['uid'] )) {
			$where ['uid !='] = $data ['uid'];
		}
		return $this->exist ( $where ) ? "邮箱地址已经存在" : apply_filter ( 'check_vip_email', true, $value, $data );
	}	
	/**
	 * 
	 * 登录
	 * @param string $account
	 * @param string $pwd
	 */
	public function login($account, $pwd) {
		return true;
	}
}